﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Threading.Tasks;

namespace IniTechCaash.Domain.Entities
{
    /// <summary>
    /// A single line in a <see cref="JounralEntry"/>. 
    /// </summary>
    public class JournalEntryLine : AuditableEntity
    {
        /// <summary>
        /// The source or destination <see cref="Account"/>. 
        /// </summary>
        public virtual Account Account { get; set; }

        /// <summary>
        /// The amount in this line. 
        /// </summary>
        public decimal Amount { get; set; }

        /// <summary>
        /// The date of the event which this entry represents. 
        /// </summary>
        [Required]
        public DateTime Date { get; set; }

        /// <summary>
        /// Description of this line. 
        /// </summary>
        [StringLength(256)]
        public string Description { get; set; }

        public override string Descriptive
        {
            get { return "JEL"; }
        }

        /// <summary>
        /// Parent <see cref="JournalEntry"/> to which this line belongs. 
        /// </summary>
        public virtual JournalEntry JournalEntry { get; set; }

        /// <summary>
        /// Whether this line is a credit or a debit. 
        /// </summary>
        public NormalSide Side { get; set; }
    }
}
